<header class="navbar navbar-static-top bs-docs-nav navbar-inverse" id="top">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#bs-navbar" aria-controls="bs-navbar"
                aria-expanded="true">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="/" class="navbar-brand">娱乐新闻网</a>
        </div>
        <nav id="bs-navbar" class="navbar-collapse collapse in" aria-expanded="true">
            <ul class="nav navbar-nav">
                <li class=<%- title==="index" ? "active" :"" %> >
                    <a href="/">首页</a>
                </li>
                <li class=<%- title==="television" ? "active" :"" %> >
                    <a href="/television">电视</a>
                </li>
                <li class=<%- title==="movie" ? "active" :"" %> >
                    <a href="/movie">电影</a>
                </li>
                <li class=<%- title==="star" ? "active" :"" %> >
                    <a href="/star">明星</a>
                </li>
                <li class=<%- title==="music" ? "active" :"" %> >
                    <a href="/music">音乐</a>
                </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">个人中心
                        <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <% if(session_username){ %>
                        <li><a style="text-align:center;" data-toggle="modal" data-target="#chat_modal">聊天区</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a style="text-align:center;" href="/comments/my_comments">我的评论</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a style="text-align:center;" href="/logout">注销</a></li>
                        <% }else{ %>
                        <li><a style="text-align:center;" href="/login" class="jump_login">登录</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a style="text-align:center;" href="/register">注册</a></li>
                        <% } %>
                    </ul>
                </li>
            </ul>
        </nav>
    </div>
</header>

<div class="modal fade" tabindex="-1" role="dialog" id="chat_modal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">聊天交流区</h4>
            </div>
            <div class="modal-body">
                <div id="chatroom" style="overflow-x: auto;height: 300px;"></div>
            </div>
            <div class="modal-footer">
                <div class="form-group cl col-sm-12 col-xs-12">
                    <div class="col-sm-10 col-xs-10">
                        <input type="text" class="form-control search" placeholder="请输入内容" id="chatword">
                    </div>
                    <button class="btn btn-primary col-sm-2 col-xs-2 search_btn" onclick="send()">发送</button>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    function send() {
        ws.send(chatword.value);  // 往服务器发送消息 
        chatword.value = "";
    }

    document.onkeyup = function (e) {
        if (e.keyCode == 13) {
            send();
        }
    }
</script>